using Application.Abstractions.Messaging;
using Domain.Todos.Events;
using Microsoft.Extensions.Logging;

namespace Application.Todos.Delete;

/// <summary>
/// 待办事项删除事件处理器
/// </summary>
public sealed class TodoItemDeletedEventHandler(ILogger<TodoItemDeletedEventHandler> logger)
    : DomainEventHandler<TodoItemDeletedEvent>
{
    public override async ValueTask Handle(TodoItemDeletedEvent notification, CancellationToken cancellationToken = default)
    {
        logger.LogInformation(
            "用户 {UserId} 删除了待办事项: {Description} (删除时间: {DeletedAt})",
            notification.UserId,
            notification.Description,
            notification.DeletedAt);

        // 这里可以添加其他业务逻辑，比如：
        // - 记录删除日志
        // - 清理相关数据
        // - 发送删除通知
        // - 更新统计信息

        await Task.CompletedTask;
    }
}
